#!/bin/sh

#####
# KinD integration test debugging tools
#
# Binary not on your host? -- `brew install ...`
#####

alias kint="act --secret-file kind/.secrets --workflows ./.github/workflows/main.yml --job integration --platform self-hosted=ghcr.io/catthehacker/ubuntu:act-20.04 --privileged --bind --eventpath kind/act.json"
alias kintd="docker run --network kind --rm -it -v $PWD/kind/kubeconfig:/root/.kube/config quay.io/derailed/k9s"
alias kintk="docker run -v $PWD/kind/kubeconfig:/.kube/config --rm --network kind bitnami/kubectl"
alias kintnet="docker run --rm -it --network kind nicolaka/netshoot bash"
alias klint="actionlint .github/workflows/main.yml"
# TODO: the `kintprep` alias doesn't work with /bin/bash
alias kintprep="docker build -t otomi/core:$(echo ${$(git rev-parse --abbrev-ref HEAD)##*/}) ."

kintoto() {
  docker run --rm -it --network kind -v "$PWD"/kind/kubeconfig:/home/app/.kube/config -v "$PWD"/tests/kind:/home/app/stack/env -e CI=1 otomi/core:$(echo ${$(git rev-parse --abbrev-ref HEAD)##*/}) "$@"
}